﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spring.Core.IO;
using Spring.Objects.Factory.Xml;
using Spring.Objects.Factory;

namespace ExcelImportComponent.Valider
{
    public class ValiderFactory
    {
        private ValiderFactory()
        {
        }
        private static ValiderFactory obj;



        private IVaild _GetValider(string key)
        {
            string path = SysUtility.GetGloablFile("ExcelValidObjects.xml");
            IResource input = new FileSystemResource(path);
            IObjectFactory factory = new XmlObjectFactory(input);
            object obj = factory.GetObject(key);
            return (IVaild)obj;
        }

        /// <summary>
        /// 获取对应Key的Builder
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static IVaild GetValider(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new Exception("ChartBuilder Key 不能为空");
            }
            if (obj == null)
            {
                obj = new ValiderFactory();
            }
            return obj._GetValider(key);
        }
    }
}
